﻿using ProtoImaginer.ProtoProject;
/* 
    Copyright (c) 2011 Microsoft Corporation.  All rights reserved.
    Use of this sample source code is subject to the terms of the Microsoft license 
    agreement under which you licensed this sample source code and is provided AS-IS.
    If you did not accept the terms of the license agreement, you are not authorized 
    to use this sample source code.  For the terms of the license, please see the tr
    license agreement between you and Microsoft.
  
    To see all Code Samples for Windows Phone, visit http://go.microsoft.com/fwlink/?LinkID=219604 
  
*/
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;

namespace ProtoImaginer.Models
{

    public class ProtoDataContext : DataContext
    {
        public static string DBConnectionString = "Data Source=isostore:/DB.sdf";

        // Pass the connection String to the base class.
        public ProtoDataContext(String connectionString)
            : base(connectionString)
        { }

        // Specify a table for the Projects.
        public Table<Project> Projects
        {
            get
            {
                return this.GetTable<Project>();
            }
        }

        // Specify a table for the Pages.
        public Table<Page> Pages
        {
            get
            {
                return this.GetTable<Page>();
            }
        }

        //Specify a table for the Controls.
        public Table<Control> Controls;
        //{
        //    get
        //    {
        //        return this.GetTable<Control>();
        //    }
        //}

        //Specify a table for the Images.
        public Table<Image> Images
        {
            get
            {
                return this.GetTable<Image>();
            }
        }

        ////Unused relation declaration
        ////Specify an association table for "A page contains up to 7 images."
        //public Table<Page_Contain_Image> PageImageList;

        ////Specify an association table for "An image contains a N controls."
        //public Table<Image_Contain_Control> ImageControlList;

        #region DB interfaces
        //control related interface
        public IList<Control> LoadControlsByImageId(String imageId)
        {
            using (ProtoDataContext controlDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Control> control = from a in controlDB.Controls
                                              where a.ControlResidingImageId == imageId
                                              select a;
                return control.ToList();
            }
        }

        public Control LoadControlByPK(String ControlId)
        {
            using (ProtoDataContext controlDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Control> control = from a in controlDB.Controls
                                              where a.ControlId == ControlId
                                              select a;
                return control.FirstOrDefault();
            }
        }

        public bool SaveControl(Control c)
        {
            using (ProtoDataContext controlDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                IQueryable<Control> control = from a in controlDB.Controls
                                              where a.ControlId == c.ControlId
                                              select a;

                foreach (Control c1 in control)
                {
                    c1.Control_Top_Left_Point_X_Coordinate = c.Control_Top_Left_Point_X_Coordinate;
                    c1.Control_Top_Left_Point_Y_Coordinate = c.Control_Top_Left_Point_Y_Coordinate;
                    c1.Control_Height = c.Control_Height;
                    c1.Control_Width = c.Control_Width;
                    c1.ControlLinkToImageId = c.ControlLinkToImageId;
                    c1.ControlResidingImageId = c.ControlResidingImageId;
                    c1.ControlStatus = c.ControlStatus;
                }


                try
                {
                    controlDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        public bool AddControl(Control c)
        {
            using (ProtoDataContext controlDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                controlDB.Controls.InsertOnSubmit(c);

                try
                {
                    controlDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    controlDB.SubmitChanges();
                }

                return true;
            }
        }

        //Assuming we delete the record from db directly rather than set the status of control to be deleted
        public bool DeleteControl(Control c)
        {
            using (ProtoDataContext controlDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Control> control = from a in controlDB.Controls
                                              where a.ControlId == c.ControlId
                                              select a;

                foreach (var c1 in control)
                {
                    controlDB.Controls.DeleteOnSubmit(c1);
                }

                try
                {
                    controlDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        //image related interface
        public IList<Image> LoadImagesByPageId(String pageId)
        {
            using (ProtoDataContext imageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Image> images = from a in imageDB.Images
                                           where a.PageId == pageId
                                           select a;
                return images.ToList();
            }
        }

        public Image LoadImageByPK(String imageId)
        {
            using (ProtoDataContext imageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Image> image = from a in imageDB.Images
                                          where a.ImageId == imageId
                                          select a;
                return image.FirstOrDefault();
            }
        }

        public bool SaveImage(Image i)
        {
            using (ProtoDataContext imageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                IQueryable<Image> image = from a in imageDB.Images
                                          where a.ImageId == i.ImageId
                                          select a;

                foreach (Image i1 in image)
                {
                    i1.PageId = i.PageId;
                    i1.ImageTitle = i.ImageTitle;
                    i1.ImageStatus = i.ImageStatus;
                    i1.ImageSequence = i.ImageSequence;
                    i1.ImageBackgroundName = i.ImageBackgroundName;
                    i1.ImageLastModifiedDate = DateTime.Now;
                }


                try
                {
                    imageDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        public bool AddImage(Image i)
        {
            using (ProtoDataContext imageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                imageDB.Images.InsertOnSubmit(i);

                try
                {
                    imageDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    imageDB.SubmitChanges();
                }

                return true;
            }
        }

        //1. Assuming we delete the record from db directly rather than set the status of image to be deleted
        //2. The foreign key reference has not been figured out so the deletion of controls of this image haven't been deleted automatically, guess it would be done through FK reference
        public bool DeleteImage(Image i)
        {
            using (ProtoDataContext imageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Image> image = from a in imageDB.Images
                                              where a.ImageId == i.ImageId
                                              select a;

                foreach (var i1 in image)
                {
                    imageDB.Images.DeleteOnSubmit(i1);
                }

                try
                {
                    imageDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        //page related interface
        public IList<Page> LoadPagesByProjectId(String projectId)
        {
            using (ProtoDataContext pageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Page> page = from a in pageDB.Pages
                                        where a.ProjectId == projectId
                                        select a;
                return page.ToList();
            }
        }
        public Page LoadPageByPK(String pageId)
        {
            using (ProtoDataContext pageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Page> page = from a in pageDB.Pages
                                        where a.PageId == pageId
                                        select a;
                return page.FirstOrDefault();
            }
        }
        public bool SavePage(Page p)
        {
            using (ProtoDataContext pageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                IQueryable<Page> page = from a in pageDB.Pages
                                        where a.PageId == p.PageId
                                        select a;

                foreach (Page p1 in page)
                {
                    p1.ProjectId = p.ProjectId;
                    p1.PageStatus = p.PageStatus;
                    p1.PageCapacity = p.PageCapacity;
                }

                try
                {
                    pageDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        public bool AddPage(Page p)
        {
            using (ProtoDataContext pageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                pageDB.Pages.InsertOnSubmit(p);

                try
                {
                    pageDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    pageDB.SubmitChanges();
                }

                return true;
            }
        }

        //1. Assuming we delete the record from db directly rather than set the status of page to be deleted
        //2. The foreign key reference has not been figured out so the deletion of images of this page haven't been deleted automatically, guess it would be done through FK reference
        public bool DeletePage(Page p)
        {
            using (ProtoDataContext pageDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Page> page = from a in pageDB.Pages
                                          where a.PageId== p.PageId
                                          select a;

                foreach (var p1 in page)
                {
                    pageDB.Pages.DeleteOnSubmit(p1);
                }

                try
                {
                    pageDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        //project related interface
        public IList<Project> LoadAllProjects()
        {
            using (ProtoDataContext projectDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Project> projects = from a in projectDB.Projects
                                               select a;
                return projects.ToList();
            }
        }
        public IList<Project> LoadProjectsByTag(String tag)
        {
            using (ProtoDataContext projectDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Project> projects = from a in projectDB.Projects
                                               where a.ProjectTag == tag
                                               select a;
                return projects.ToList();
            }
        }

        public Project LoadProjectByPK(String projectId)
        {
            using (ProtoDataContext projectDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Project> project = from a in projectDB.Projects
                                              where a.ProjectId == projectId
                                              select a;
                return project.FirstOrDefault();
            }
        }

        public bool SaveProject(Project p)
        {
            using (ProtoDataContext projectDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                IQueryable<Project> project = from a in projectDB.Projects
                                              where a.ProjectId == p.ProjectId
                                              select a;

                foreach (Project p1 in project)
                {
                    p1.ProjectName = p.ProjectName;
                    p1.ProjectDescription = p.ProjectDescription;
                    p1.ProjectAuthor = p1.ProjectAuthor;
                    p1.ProjectLastModifiedDate = DateTime.Now;
                    p1.ProjectStatus = p.ProjectStatus;
                    p1.ProjectTag = p.ProjectTag;
                }

                try
                {
                    projectDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }

        public bool AddProject(Project p)
        {
            using (ProtoDataContext projectDB = new ProtoDataContext("isostore:/DB.sdf"))
            {

                projectDB.Projects.InsertOnSubmit(p);

                try
                {
                    projectDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    projectDB.SubmitChanges();
                }

                return true;
            }
        }

        //1. Assuming we delete the record from db directly rather than set the status of project to be deleted
        //2. The foreign key reference has not been figured out so the deletion of pages of this project haven't been deleted automatically, guess it would be done through FK reference
        public bool DeleteProject(Project p)
        {
            using (ProtoDataContext projectDB = new ProtoDataContext("isostore:/DB.sdf"))
            {
                IQueryable<Project> project = from a in projectDB.Projects
                                        where a.ProjectId == p.ProjectId
                                        select a;

                foreach (var p1 in project)
                {
                    projectDB.Projects.DeleteOnSubmit(p1);
                }

                try
                {
                    projectDB.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return true;
            }
        }
     #endregion
    }

        

        #region table definations

        [Table]
        public class Project : INotifyPropertyChanged, INotifyPropertyChanging
        {
            public Project()
            {
                Guid id = new Guid();
                ProjectId = id.ToString();
                ProjectAuthor = 0;
                ProjectCreateDate = DateTime.Now;
                ProjectLastModifiedDate = DateTime.Now;
                ProjectName = "untitled";
                ProjectDescription = "no description";
                ProjectTag = "";
                ProjectStatus = (int)GlobalVariables.projectStatus.Independent;
                /* Not Sure Propoties */

            }

            public Project(String ProjectId, int ProjectAuthor, String ProjectName, String ProjectDescription, String ProjectTag)
            {
                this.ProjectId = ProjectId;
                this.ProjectAuthor = ProjectAuthor;
                this.ProjectName = ProjectName;
                this.ProjectDescription = ProjectDescription;
                this.ProjectTag = ProjectTag;
                this.ProjectCreateDate = DateTime.Now;
                this.ProjectLastModifiedDate = DateTime.Now;
            }

            public Project(String ProjectId, int ProjectAuthor, String ProjectName, int ProjectStatus,
                String ProjectDescription, String ProjectTag, DateTime ProjectCreateDate, DateTime ProjectLastModifiedDate)
            {
                this.ProjectId = ProjectId;
                this.ProjectAuthor = ProjectAuthor;
                this.ProjectName = ProjectName;
                this.ProjectStatus = ProjectStatus;
                this.ProjectDescription = ProjectDescription;
                this.ProjectTag = ProjectTag;
                this.ProjectCreateDate = ProjectCreateDate;
                this.ProjectLastModifiedDate = ProjectLastModifiedDate;
            }

            // Define ID: private field, public property, and database column.
            [Column(IsPrimaryKey = true, CanBeNull = false)]
            public String ProjectId
            {
                get;
                set;
            }

            // Define item name: private field, public property, and database column.
            [Column(CanBeNull = false)]
            public String ProjectName
            {

                get;
                set;
            }

            //Define the description
            [Column]
            public String ProjectDescription
            {

                get;
                set;
            }

            //Define the keywords
            [Column]
            public String ProjectTag
            {

                get;
                set;
            }

            //Define the Author
            [Column]
            public int ProjectAuthor
            {

                get;
                set;
            }

            //Define the Project CreateDate
            [Column]
            public DateTime ProjectCreateDate
            {

                get;
                set;
            }

            //Define the Project LastModifiedDate
            [Column]
            public DateTime ProjectLastModifiedDate
            {

                get;
                set;
            }

            //Define the project status
            [Column]
            public int ProjectStatus
            {

                get;
                set;
            }

            // Version column aids update performance.
            //[Column(IsVersion = true)]
            //private Binary _version;

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            // Used to notify that a property changed
            private void NotifyPropertyChanged(String propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #endregion

            #region INotifyPropertyChanging Members

            public event PropertyChangingEventHandler PropertyChanging;

            // Used to notify that a property is about to change
            private void NotifyPropertyChanging(String propertyName)
            {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
                }
            }

            #endregion

        }

        [Table]
        public class Page : INotifyPropertyChanged, INotifyPropertyChanging
        {
            public Page(String projectId)
            {
                Guid id = new Guid();
                PageId = id.ToString();
                this.ProjectId = projectId;
                this.PageStatus = (int)GlobalVariables.pageStatus.Independent;
                //A page contains at most 7 images.
                //PageCapacity decreases by 1 once a new image created under this page. 
                //A new page has to be created once PageCapacity reaches 0.
                this.PageCapacity = GlobalVariables.maximumPageCapacity;
            }


            public Page(String pageId, String projectId, int pageStatus)
            {
                this.PageId = pageId;
                this.ProjectId = projectId;
                this.PageStatus = pageStatus;
                //A page contains at most 7 images. 
                //PageCapacity decreases by 1 once a new image created under this page. 
                //A new page has to be created once PageCapacity reaches 0.
                this.PageCapacity = GlobalVariables.maximumPageCapacity;
            }

            [Column(IsPrimaryKey = true, CanBeNull = false)]
            public String PageId
            {

                get;
                set;
            }

            //Foreign key
            [Column(CanBeNull = false)]
            public String ProjectId
            {
                get;
                set;
            }

            [Column]
            public int PageStatus
            {
                get;
                set;
            }

            //A page contains at most 7 images.
            [Column]
            public int PageCapacity
            {
                get;
                set;
            }

            // Version column aids update performance.
            //[Column(IsVersion = true)]
            //private Binary _version;

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            // Used to notify that a property changed
            private void NotifyPropertyChanged(String propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #endregion

            #region INotifyPropertyChanging Members

            public event PropertyChangingEventHandler PropertyChanging;

            // Used to notify that a property is about to change
            private void NotifyPropertyChanging(String propertyName)
            {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
                }
            }

            #endregion
        }

        [Table]
        public class Image : INotifyPropertyChanged, INotifyPropertyChanging
        {
            public Image()
            {
                Guid id = new Guid();
                ImageId = id.ToString();
                ImageTitle = "untitled";
                ImageSequence = -1;
                Guid imageName = new Guid();
                ImageBackgroundName = imageName.ToString();
                ImageCreateDate = DateTime.Now;
                ImageLastModifiedDate = DateTime.Now;
                ImageStatus = (int)GlobalVariables.imageStatus.Independent;

            }
            public Image(String imageId, String imageTitle, int imageSequence,
                String imageBackgroundName, DateTime imageCreateDate, DateTime imageLastModifiedDate, int imageStatus)
            {
                this.ImageId = imageId;
                this.ImageTitle = imageTitle;
                this.ImageSequence = imageSequence;
                this.ImageBackgroundName = imageBackgroundName;
                this.ImageCreateDate = imageCreateDate;
                this.ImageLastModifiedDate = imageLastModifiedDate;
                this.ImageStatus = imageStatus;
            }

            // Define ID: private field, public property, and database column.

            [Column(IsPrimaryKey = true, CanBeNull = false)]
            public String ImageId
            {

                get;
                set;
            }

            //Foreign key
            [Column]
            public String PageId
            {

                get;
                set;
            }

            [Column]
            public String ImageTitle
            {
                get;
                set;
            }

            //let's say the sequence id assigned to this page within the project, e.g. 1, 2, 3
            [Column]
            public int ImageSequence
            {
                get;
                set;
            }

            ////unique name of background image
            [Column]
            public String ImageBackgroundName
            {
                get;
                set;
            }

            [Column]
            public DateTime ImageCreateDate
            {
                get;
                set;
            }

            [Column]
            public DateTime ImageLastModifiedDate
            {
                get;
                set;
            }

            [Column]
            public int ImageStatus
            {
                get;
                set;
            }

            // Version column aids update performance.
            //[Column(IsVersion = true)]
            //private Binary _version;

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            // Used to notify that a property changed
            private void NotifyPropertyChanged(String propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #endregion

            #region INotifyPropertyChanging Members

            public event PropertyChangingEventHandler PropertyChanging;

            // Used to notify that a property is about to change
            private void NotifyPropertyChanging(String propertyName)
            {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
                }
            }

            #endregion
        }

        [Table]
        public class Control : INotifyPropertyChanged, INotifyPropertyChanging
        {
            public Control(String residingPageId)
            {
                Guid id = new Guid();
                ControlId = id.ToString();
                Control_Top_Left_Point_X_Coordinate = 0;
                Control_Top_Left_Point_Y_Coordinate = 0;
                Control_Width = 100;
                Control_Height = 75;
                this.ControlResidingImageId = residingPageId;
                ControlStatus = (int)GlobalVariables.controlStatus.Independent;
                ControlCreateDate = DateTime.Now;
            }


            public Control(String controlId, int top_left_x, int top_left_y,
                int width, int height, String residingPageId, String linkToPageId, int status, DateTime createDate)
            {
                this.ControlId = controlId;
                this.Control_Top_Left_Point_X_Coordinate = top_left_x;
                this.Control_Top_Left_Point_Y_Coordinate = top_left_y;
                this.Control_Width = width;
                this.Control_Height = height;
                this.ControlResidingImageId = residingPageId;
                this.ControlLinkToImageId = linkToPageId;
                this.ControlStatus = status;
                this.ControlCreateDate = createDate;
            }

            [Column(IsPrimaryKey = true, CanBeNull = false)]
            public String ControlId
            {

                get;
                set;
            }

            [Column(CanBeNull = false)]
            public int Control_Top_Left_Point_X_Coordinate
            {
                get;
                set;
            }

            [Column(CanBeNull = false)]
            public int Control_Top_Left_Point_Y_Coordinate
            {
                get;
                set;
            }

            [Column(CanBeNull = false)]
            public int Control_Width
            {
                get;
                set;
            }

            [Column(CanBeNull = false)]
            public int Control_Height
            {
                get;
                set;
            }

            //Foreign key
            [Column(CanBeNull = false)]
            public String ControlResidingImageId
            {

                get;
                set;
            }

            //Foreign key
            [Column]
            public String ControlLinkToImageId
            {
                get;
                set;
            }

            [Column]
            public int ControlStatus
            {
                get;
                set;
            }

            [Column]
            public DateTime ControlCreateDate
            {
                get;
                set;
            }

            // Version column aids update performance.
            //[Column(IsVersion = true)]
            //private Binary _version;

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            // Used to notify that a property changed
            private void NotifyPropertyChanged(String propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #endregion

            #region INotifyPropertyChanging Members

            public event PropertyChangingEventHandler PropertyChanging;

            // Used to notify that a property is about to change
            private void NotifyPropertyChanging(String propertyName)
            {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
                }
            }

            #endregion
        }

        //[Table] unused page class
        //public class Page : INotifyPropertyChanged, INotifyPropertyChanging
        //{
        //    public Page() 
        //    {
        //        Guid id = new Guid();
        //        PageId = id.ToString();
        //        PageTitle = "untitled";
        //        PageAuthor = 0;
        //        PageStatus = 0;
        //        PageCreateDate = DateTime.Now;
        //        PageLastModifiedDate = DateTime.Now;
        //    }
        //    public Page(String PageId, String PageTitle, int PageAuthor, Guid PageProjectId,
        //        DateTime PageCreateDate, DateTime PageLastModifiedDate, int PageStatus)
        //    {
        //        this.PageId = PageId;
        //        this.PageTitle = PageTitle;
        //        this.PageAuthor = PageAuthor;
        //        this.PageStatus = PageStatus;
        //        this.PageCreateDate = PageCreateDate;
        //        this.PageLastModifiedDate = PageLastModifiedDate;
        //    }

        //    // Define ID: private field, public property, and database column.

        //    [Column(IsPrimaryKey = true, CanBeNull = false)]
        //    public String PageId
        //    {

        //        get;
        //        set;
        //    }

        //    // Define category name: private field, public property, and database column.

        //    [Column]
        //    public String PageTitle
        //    {

        //        get;
        //        set;
        //    }

        //    //Define the Author

        //    [Column]
        //    public int PageAuthor
        //    {

        //        get;
        //        set;
        //    }


        //    [Column]
        //    public String PageProjectId
        //    {

        //        get;
        //        set;
        //    }

        //    //Define the Project CreateDate

        //    [Column]
        //    public DateTime PageCreateDate
        //    {

        //        get;
        //        set;
        //    }

        //    //Define the Project LastModifiedDate

        //    [Column]
        //    public DateTime PageLastModifiedDate
        //    {

        //        get;
        //        set;
        //    }

        //    //Define the project status

        //    [Column]
        //    public int PageStatus
        //    {

        //        get;
        //        set;
        //    }


        //    // Version column aids update performance.
        //    //[Column(IsVersion = true)]
        //    //private Binary _version;

        //    #region INotifyPropertyChanged Members

        //    public event PropertyChangedEventHandler PropertyChanged;

        //    // Used to notify that a property changed
        //    private void NotifyPropertyChanged(String propertyName)
        //    {
        //        if (PropertyChanged != null)
        //        {
        //            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        //        }
        //    }

        //    #endregion

        //    #region INotifyPropertyChanging Members

        //    public event PropertyChangingEventHandler PropertyChanging;

        //    // Used to notify that a property is about to change
        //    private void NotifyPropertyChanging(String propertyName)
        //    {
        //        if (PropertyChanging != null)
        //        {
        //            PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        //        }
        //    }

        //    #endregion
        //}

        //[Table] unused relations
        //public class Image_Contain_Control : INotifyPropertyChanged, INotifyPropertyChanging
        //{

        //    public Image_Contain_Control(String controlId, String imageId)
        //    {
        //        this.ControlId = controlId;
        //        this.ImageId = imageId;
        //    }

        //    //A unique control can only be contained by exactly 1 image.
        //    //A image can contain * controls
        //    [Column(IsPrimaryKey = true, CanBeNull = false)] 
        //    public String ControlId
        //    {

        //        get;
        //        set;
        //    }

        //    //Foreign key
        //    [Column(CanBeNull = false)]
        //    public String ImageId
        //    {
        //        get;
        //        set;
        //    }

        //    // Version column aids update performance.
        //    //[Column(IsVersion = true)]
        //    //private Binary _version;

        //    #region INotifyPropertyChanged Members

        //    public event PropertyChangedEventHandler PropertyChanged;

        //    // Used to notify that a property changed
        //    private void NotifyPropertyChanged(String propertyName)
        //    {
        //        if (PropertyChanged != null)
        //        {
        //            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        //        }
        //    }

        //    #endregion

        //    #region INotifyPropertyChanging Members

        //    public event PropertyChangingEventHandler PropertyChanging;

        //    // Used to notify that a property is about to change
        //    private void NotifyPropertyChanging(String propertyName)
        //    {
        //        if (PropertyChanging != null)
        //        {
        //            PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        //        }
        //    }

        //    #endregion
        //}

        //[Table]
        //public class Page_Contain_Image : INotifyPropertyChanged, INotifyPropertyChanging
        //{

        //    public Page_Contain_Image(String imageId, String pageId)
        //    {
        //        this.ImageId = imageId;
        //        this.PageId = pageId;
        //    }

        //    //Assume a unique image object (not the picture) can only be contained by exactly 1 page.
        //    //A page can contain up to 7 images.
        //    [Column(IsPrimaryKey = true, CanBeNull = false)]
        //    public String ImageId
        //    {

        //        get;
        //        set;
        //    }

        //    //Foreign key
        //    [Column(CanBeNull = false)]
        //    public String PageId
        //    {
        //        get;
        //        set;
        //    }

        //    // Version column aids update performance.
        //    //[Column(IsVersion = true)]
        //    //private Binary _version;

        //    #region INotifyPropertyChanged Members

        //    public event PropertyChangedEventHandler PropertyChanged;

        //    // Used to notify that a property changed
        //    private void NotifyPropertyChanged(String propertyName)
        //    {
        //        if (PropertyChanged != null)
        //        {
        //            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        //        }
        //    }

        //    #endregion

        //    #region INotifyPropertyChanging Members

        //    public event PropertyChangingEventHandler PropertyChanging;

        //    // Used to notify that a property is about to change
        //    private void NotifyPropertyChanging(String propertyName)
        //    {
        //        if (PropertyChanging != null)
        //        {
        //            PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        //        }
        //    }

        //    #endregion
        //}

        #endregion
    }
